import http from '@/utils/http'

const BASE_URL = '/cakerun/storeMetrics'

export interface StoreMetricsResp {
  id: string
  businessTime: string
  shopId: string
  shopName: string
  province: string
  city: string
  exposureCount: string
  exposureCountRingRatio: string
  visitCount: string
  visitCountRingRatio: string
  exposureToVisitRate: string
  exposureToVisitRateRingRatio: string
  visitToPurchaseRate: string
  visitToPurchaseRateRingRatio: string
  rosScore: string
  rosScoreRingRatio: string
  createUserString: string
  updateUserString: string
  disabled: boolean
}
export interface StoreMetricsDetailResp {
  id: string
  businessTime: string
  shopId: string
  shopName: string
  province: string
  city: string
  exposureCount: string
  exposureCountRingRatio: string
  visitCount: string
  visitCountRingRatio: string
  exposureToVisitRate: string
  exposureToVisitRateRingRatio: string
  visitToPurchaseRate: string
  visitToPurchaseRateRingRatio: string
  rosScore: string
  rosScoreRingRatio: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  enable: string
  createUserString: string
  updateUserString: string
}
export interface StoreMetricsQuery {
  accountId?: string
  businessTime: string | undefined
  shopId: string | undefined
  shopName: string | undefined
  province: string | undefined
  city: string | undefined
  exposureCount: string | undefined
  exposureCountRingRatio: string | undefined
  visitCount: string | undefined
  visitCountRingRatio: string | undefined
  exposureToVisitRate: string | undefined
  exposureToVisitRateRingRatio: string | undefined
  visitToPurchaseRate: string | undefined
  visitToPurchaseRateRingRatio: string | undefined
  rosScore: string | undefined
  rosScoreRingRatio: string | undefined
  sort: Array<string>
}
export interface StoreMetricsPageQuery extends StoreMetricsQuery, PageQuery {}

/** @desc 查询指标列表 */
export function listStoreMetrics(query: StoreMetricsPageQuery) {
  return http.get<PageRes<StoreMetricsResp[]>>(BASE_URL, query)
}

/** @desc 查询指标详情 */
export function getStoreMetrics(id: string) {
  return http.get<StoreMetricsDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增指标 */
export function addStoreMetrics(data: any) {
  return http.post(BASE_URL, data)
}

/** @desc 修改指标 */
export function updateStoreMetrics(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除指标 */
export function deleteStoreMetrics(id: string) {
  return http.del(BASE_URL, { ids: [id] })
}

/** @desc 导出指标 */
export function exportStoreMetrics(query: StoreMetricsQuery) {
  return http.download(`${BASE_URL}/export`, query)
}
